<%@page import="java.sql.ResultSet"%>
<%@page import="database.DBConnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <body>
        <div id="main">
            <jsp:include page="topBar.jsp"></jsp:include>
            <div id="all">
                <div id="content">
                    <h2>Kundekardotek</h2>
                    <div id="customerBar">
                        <div id="tlfBoxHead">Telefonnummer</div>
                        <div id="nameBoxHead">Navn</div>
                        <div id="emailBoxHead">Email</div><br>
                        <%
                                    DBConnector dbc = DBConnector.getDBC();
                                    ResultSet rs = dbc.doQuery("SELECT * FROM customers ORDER BY TelephoneNumber;");
                                    int idx = 0;
                                    while (rs.next()) {
                                        if ((idx % 2) == 0) {
                                            String tlf = rs.getString(1);
                                            String name = rs.getString(3) + " " + rs.getString(4);
                                            String email = rs.getString(5);
                                            out.println("<div id=\"tlfBox1\">" + tlf + "</div>");
                                            out.println("<div id=\"nameBox1\">" + name + "</div>");
                                            out.println("<div id=\"emailBox1\">" + email + "</div><br>");
                                        } else {
                                            String tlf = rs.getString(1);
                                            String name = rs.getString(3) + " " + rs.getString(4);
                                            String email = rs.getString(5);
                                            out.println("<div id=\"tlfBox2\">" + tlf + "</div>");
                                            out.println("<div id=\"nameBox2\">" + name + "</div>");
                                            out.println("<div id=\"emailBox2\">" + email + "</div><br>");
                                        }
                                        idx++;
                                    }
                        %>
                    </div>
                </div>
                <jsp:include page="navigationBar.jsp"></jsp:include>
            </div>
        </div>
    </body>
</html>